// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
import axios from "axios";
import VueAxios from "vue-axios";
import ElemetntUi from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import App from "./App";
import router from "./router";
import "default-passive-events";
import echarts from 'echarts'
Vue.prototype.$echarts = echarts

Vue.use(ElemetntUi);
Vue.use(VueAxios, axios);

Vue.config.productionTip = false;

/* eslint-disable no-new */
new Vue({
  el: "#app",
  router,
  components: { App },
  template: "<App/>"
});

router.beforeEach((to, from, next) => {
  if (to.path === "/login" || to.path === "/register") {
    next();
    return;
  }
  if (localStorage.token) {
    next();
  } else {
    next({ path: "/login" });
  }
});


// 通过环境判断请求地址l
var address = ""

if (process.env.NODE_ENV=="dev") {
  address ="http://192.168.1.51:8000/api"  // 本地
}else{
  address = "http://62.234.59.209:8888/api"   // 服务器
}

console.log(address);

export{
  address    // 返回出去
}
